<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

	<head>
		<meta charset="utf-8"/>
		<title>修改文章状态</title>
		<meta name="renderer" content="webkit"/>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
		<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
		<meta name="apple-mobile-web-app-capable" content="yes"/>
		<meta name="format-detection" content="telephone=no"/>

		<link rel="stylesheet" href="/layui/plugins/layui/css/layui.css" media="all" />
		<script src="/main/js/jquery.min.js"></script>
        <script src="/main/js/template-web.js"></script>
        <script src="/layui/plugins/layui/layui.js"></script>
    </head>

	<body>

    <input type="hidden" id="user2" th:value="${session.user}"/>
    <input type="hidden" id="paperId" th:value="${paperId}"/>
		<div style="margin: 15px;">
			<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
				<legend>状态修改</legend>
			</fieldset>

			<form class="layui-form" action="" style="height: 100%" >
				<div class="layui-form-item">
					<label class="layui-form-label">更改文章状态</label>
					<div class="layui-input-block">
						<!--优化方案 数据库中建立 审核候选表 从表中获取内容-->
						<select name="review" lay-verify="required">
							<option value="审核通过">审核通过</option>
							<option value="审核失败">涉嫌违规，不能通过</option>
						</select>
					</div>
				</div>

				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>
		</div>
		<script>
			layui.use(['form', 'layedit', 'laydate'], function() {
				var form = layui.form,
					layer = layui.layer,
					layedit = layui.layedit,
					laydate = layui.laydate;

				//监听提交
				form.on('submit(demo1)', function(data) {
					layer.alert(JSON.stringify(data.field), {
						title: '最终的提交信息'
					});
                    var paperId = document.getElementById("paperId").value;
					$.ajax({
                        type : "post",
                        data:data.field,
                        dataType:"json",
                        url :'/paper/updatePaperStatus/'+paperId,
                        timeout : 20000,
                        cache : false,
                        success:function (data) {
                            if(data == 1){
                                layer.alert("更改成功");
                                parent.layer.closeAll('fix');
                            }
                            else{
                                layer.alert("出错了");
                                layer.closeAll('fix');
                            }

                        }
                    });
					return false;
				});
			});
		</script>
	</body>

</html>